class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2022-02-12",
      revision: "07b4b32301e90787f5032e1d6a58eed2452b7b34"
  version "2022-02-12"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "02fc4b5ef6887dc2ca0cae2bb5ba08bf00ee75b920914ba9203873921f1d6dd3"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "33711487857b1f0ac401b3a87967b97513fc4743dc91ce0a2eb8ccc95d5e7e1a"
    sha256 cellar: :any_skip_relocation, monterey:       "c838acb0c2250848068b22b7ca2bbbfcbec5e65bec6eaf82ad883ad93f642836"
    sha256 cellar: :any_skip_relocation, big_sur:        "85d1264e28a3876c266d3a50cea6a8b23add37ef01a69a50ed0b4f08bdcfc898"
    sha256 cellar: :any_skip_relocation, catalina:       "ec0846b1b8a9ea111429012ea1befefd1ac20546be70ed7d30a2372bd9c86ddc"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "f50e040200fd2a229048b3c3d868ff0c22ab030374aebfb5a8fe0355a01f85cc"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
